#include "cityCore.h"

int main(){

	int semIt=2;
	int N;
	int n;
	int maxStdCars;
	int maxSpecCars;
	FILE *configFile;
	
	configFile = fopen ("cityConfig.txt", "r");
	fscanf (configFile,"\n%i",&N);
	fscanf (configFile, "\n%i", &n);
	fscanf (configFile, "\n%i", &maxStdCars);
	fscanf (configFile, "\n%i", &maxSpecCars);
	fclose (configFile);
	
	printf("Dimension de la ciudad: %ix%i\nModificador de autos por via: %i\nAutos normales: %i\nAutos Prioritarios: %i\n",N,N,n,maxStdCars,maxSpecCars);
	system("PAUSE");
	
	int maxvertex = N*N;
	Graph *city = makeGraph(maxvertex, N, n);
	carqueueList *_streetCars = carqueuePopulate(maxStdCars, maxvertex, maxSpecCars);
	graphPopulate(city, _streetCars);
	
	while(!_streetCars->checkempty()){
		if(semIt == 2){
			semIt = 0;
			system("PAUSE");
			printf("\nCamino minimo por Dijkstra\n");
			system("PAUSE");
			pathUpdate(city, _streetCars, N);
		}
		semStart(city, _streetCars, n);
		semIt++;
	}
	
    system("PAUSE");
    return 1;
}
